using System;
using System.Collections;

namespace Snooze.Controllers.Flex
{
    using Castle.MonoRail.Framework;
    using Snooze.Model;

	[Layout("flex")]
    [ControllerDetails(Area="flex")]
	public class PersonController : FlexController
	{

        public void Index()
        {
            
        }

        [AjaxAction]
        public void GetPersons()
        {
            FindAll("Alarm");
        }


        [AjaxAction]
        public void AddPerson(string name)
        {
            Person person = new Person(name);
            person.SaveAndFlush();
            GetPersons();
        }

        [AjaxAction]
        public void DeletePerson(int id)
        {
            Person person = Repository<Person>.FindById(id);
            person.DeleteAndFlush();
            GetPersons();
        }

        [AjaxAction]
        public void UpdatePerson(int id, string xml_data)
        {
            Person person = Repository<Person>.FindById(id);
            person.Xml = xml_data;
            person.SaveAndFlush();

            GetPersons();
        }

	}
}
